import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 涛
 * Date: 2023-09-25
 * Time: 21:00
 */
public class Test1 {
    public static void main(String[] args) {
        ArrayList<Integer> list1 = new ArrayList<>();
        list1.add(1);
        list1.add(2);
        list1.add(3);
        list1.add(4);
        list1.add(5);

        //迭代器
        Iterator<Integer> it = list1.iterator();
        while(it.hasNext()) {
            System.out.println(it.next());
        }

        //迭代器
//        Iterator<Integer> it = list1.iterator();
//        while(it.hasNext()) {
//            System.out.println(it.next() + " ");
//        }
    }
    public static void main5(String[] args) {
        ArrayList<Integer> list1 = new ArrayList<>();
        list1.add(1);
        list1.add(2);
        list1.add(3);
        list1.add(4);
        list1.add(5);

        for(Integer i : list1) {
            System.out.println(i);
        }

        List<Integer> list2 = list1.subList(0,2);

        list2.set(0,99);
        System.out.println(list2);
        System.out.println(list1);

//        ArrayList<Number> list2 = new ArrayList<>();
//        list2.addAll(list1);
//        System.out.println(list2);

    }
    public static void main4(String[] args) {
        Collection<Integer> collection1 = new ArrayList<>();
        Collection<Integer> collection2 = new LinkedList<>();
        Collection<Integer> collection3 = new LinkedList<>();
    }

    public static void main3(String[] args) {
        LinkedList<Integer> list1 = new LinkedList<>();
        list1.add(1);
        list1.add(2);
        list1.add(3);

        ArrayList<Number> list2 = new ArrayList<>(list1);
        System.out.println(list2);
    }
    public static void main2(String[] args) {
        ArrayList<Integer> list = new ArrayList<>();

        ArrayList<Number> list1 = new ArrayList<>(list);
    }
    //创建一个顺序表
    public static void main1(String[] args) {
        ArrayList<Integer> arrayList = new ArrayList<Integer>();
        arrayList.add(1);
        arrayList.add(2);
        arrayList.add(3);

        for (int i = 0; i < arrayList.size(); i++) {
            System.out.println(arrayList.get(i));
        }
        System.out.println("=============");

        System.out.println(arrayList);
        System.out.println("=================");

        arrayList.add(0, 99);
        System.out.println(arrayList);
    }
}
